﻿<link href="~/Scripts/jquery-easyui-extensions/treegrid/jeasyui.extensions.treegrid.css" rel="stylesheet" />
<script src="~/Scripts/jquery-easyui-extensions/treegrid/jeasyui.extensions.treegrid.liveSearch.js"></script>

<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="tg1"></table>
</div>


<script>
    $(function () {
        var getFrozenColumns = function () {
            var result = [];

            var c1 = [];
            c1.push({ field: 'AreaName', title: '地区', width: 150 });
            c1.push({ field: 'ID', title: '主键', width: 100 });
            c1.push({ field: 'Sex1', title: '男', width: 90 });
            c1.push({ field: 'Sex2', title: '女', width: 90 });

            result.push(c1);

            return result;
        };

        var getColumns = function () {
            var result = [];

            var normal = [
                { field: 'TS1', title: '测试1', width: 60 },
                { field: 'TS2', title: '测试2', width: 60 }
            ];
            result.push(normal);

            return result;
        };
        var options = {
            title: "列表",
            idField: "ID",
            treeField: "AreaName",
            rownumbers: true,
            fit: true,
            border: false,
            singleSelect: true,
            toolbar: [
                {
                    iconCls: 'icon-edit',
                    text: "根据“4”所有列高亮查询",
                    handler: function () {
                        $("#tg1").treegrid("liveSearch", "4");
                    }
                },
                "-",
                {
                    iconCls: 'icon-edit',
                    text: "根据“区”在“列：地区”高亮查询",
                    handler: function () {
                        $("#tg1").treegrid("liveSearch", { field: "AreaName", value: "区" });
                    }
                },
                "-",
                {
                    iconCls: 'icon-edit',
                    text: "根据“3”在“列：男”高亮查询",
                    handler: function () {
                        $("#tg1").treegrid("liveSearch", { field: "Sex1", value: "3" });
                    }
                },
                "-",
                {
                    iconCls: 'icon-edit',
                    text: "清除“列：男”的高亮查询后的效果",
                    handler: function () {
                        $("#tg1").treegrid("clearLiveHighLight", "Sex1");
                    }
                },
                "-",
                {
                    iconCls: 'icon-edit',
                    text: "清除所有列的高亮查询后的效果",
                    handler: function () {
                        $("#tg1").treegrid("clearLiveHighLight");
                    }
                }
            ],
            frozenColumns: getFrozenColumns(),
            columns: getColumns(),
            method: "get",
            url: "/Jsons/treegrid/treegrid-common-data.json"
        };

        $("#tg1").treegrid(options);
    });
</script>